using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class IptUI : SigtMnb<IptUI>
{
    public Sprite _emptyIpt;
    [Tooltip("Order: AXYB, normal-perfect")]
    public Sprite[] _ipts;
    public Sprite[] _words;
    public Sprite[] _pWords;
    public Sprite[] _wordNums;

    [Header("Controls")]
    public Image[] _ofsvIpts;
    /// <summary>
    /// Up, down, up, down, right.
    /// </summary>
    public Image[] _ofsvWords;

    public Image[] _dfsvIpts;
    /// <summary>
    /// Up, down, up, down, right.
    /// </summary>
    public Image[] _dfsvWords;

    private Dictionary<IptType, Sprite> _iptDic;

    private IptPrcs _ofsvPrcs;
    private IptPrcs _dfsvPrcs;

    private void Awake()
    {
        IniSigt();
    }

    void Start()
    {
        IniIptUI();
    }

    void Update()
    {

    }

    private void IniIptUI()
    {
        _ofsvPrcs = new IptPrcs(_ofsvIpts, _ofsvWords, _emptyIpt, _words, _pWords, _wordNums);
        _dfsvPrcs = new IptPrcs(_dfsvIpts, _dfsvWords, _emptyIpt, _words, _pWords, _wordNums);
        _iptDic = new Dictionary<IptType, Sprite>
        {
            { IptType.South, _ipts[0] },
            { IptType.West, _ipts[1] },
            { IptType.North, _ipts[2] },
            { IptType.East, _ipts[3] },
            { IptType.PSouth, _ipts[4] },
            { IptType.PWest, _ipts[5] },
            { IptType.PNorth, _ipts[6] },
            { IptType.PEast, _ipts[7] },
        };
    }

    public void OfsvIpt(IptType it) { _ofsvPrcs.Ipt(it, _iptDic[it]); }
    public void DfIpt(IptType it) { _dfsvPrcs.Ipt(it, _iptDic[it]); }

    public void GenOfsvWords()
    {
        _ofsvPrcs.GenWords();
        _ofsvPrcs.ClearIpt();
    }

    public void GenDfsvWords()
    {
        _dfsvPrcs.GenWords();
        _dfsvPrcs.ClearIpt();
    }

    public void ClearOfsvIpt() { _ofsvPrcs.ClearIpt(); }
    public void ClearDfsvIpt() { _dfsvPrcs.ClearIpt(); }
}
